package com.example.hsh.homefragment.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.hsh.homefragment.R;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by HSH on 2016/12/15.
 */

public class ListViewAdapter extends BaseAdapter {

    protected ArrayList<String> datas = new ArrayList<>();
    protected Context mContext;
    protected LayoutInflater inflater;

    public ListViewAdapter(Context context) {
        mContext = context;
        inflater = LayoutInflater.from(context);
    }

    public void addDatas(List<String> datas) {
        this.datas.addAll(datas);
        notifyDataSetChanged();
    }


    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = inflater.inflate(R.layout.layout_of_test_item, parent, false);
        TextView test = (TextView) view.findViewById(R.id.tv_item);
        test.setText(datas.get(position));
        return view;
    }
}
